<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="prev" href="node41.html" />
<link rel="parent" href="module-string.html" />
<link rel="next" href="module-re.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>4.1.4 Deprecated string functions</title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="4.1.3 string functions"
  href="node41.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="4.1 string  "
  href="module-string.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="4.2 re  "
  href="module-re.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="node41.html">4.1.3 String functions</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-string.html">4.1 string  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-re.html">4.2 re  </a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h2><a name="SECTION006140000000000000000">
4.1.4 Deprecated string functions</a>
</h2>

<p>
The following list of functions are also defined as methods of string and
Unicode objects; see ``String Methods'' (section
<a href="string-methods.html#string-methods">3.6.1</a>) for more information on those.  You should consider
these functions as deprecated, although they will not be removed until Python
3.0.  The functions defined in this module are:

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-360' xml:id='l2h-360' class="function">atof</tt></b>(</nobr></td>
  <td><var>s</var>)</td></tr></table></dt>
<dd>
  <div class="versionnote"><b>Deprecated since release 2.0.</b>
Use the <tt class="function">float()</tt> built-in function.</div><p></p>
  Convert a string to a floating point number.  The string must have
  the standard syntax for a floating point literal in Python,
  optionally preceded by a sign ("<tt class="samp">+</tt>" or "<tt class="samp">-</tt>").  Note that
  this behaves identical to the built-in function
  <tt class="function">float()</tt><a id='l2h-361' xml:id='l2h-361'></a> when passed a string.

<p>
<span class="note"><b class="label">Note:</b>
When passing in a string, values for NaN<a id='l2h-362' xml:id='l2h-362'></a>
  and Infinity<a id='l2h-363' xml:id='l2h-363'></a> may be returned, depending on the
  underlying C library.  The specific set of strings accepted which
  cause these values to be returned depends entirely on the C library
  and is known to vary.</span>
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-364' xml:id='l2h-364' class="function">atoi</tt></b>(</nobr></td>
  <td><var>s</var><big>[</big><var>, base</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  <div class="versionnote"><b>Deprecated since release 2.0.</b>
Use the <tt class="function">int()</tt> built-in function.</div><p></p>
  Convert string <var>s</var> to an integer in the given <var>base</var>.  The
  string must consist of one or more digits, optionally preceded by a
  sign ("<tt class="samp">+</tt>" or "<tt class="samp">-</tt>").  The <var>base</var> defaults to 10.  If it
  is 0, a default base is chosen depending on the leading characters
  of the string (after stripping the sign): "<tt class="samp">0x</tt>" or "<tt class="samp">0X</tt>"  means 16, "<tt class="samp">0</tt>" means 8, anything else means 10.  If <var>base</var>
  is 16, a leading "<tt class="samp">0x</tt>" or "<tt class="samp">0X</tt>" is always accepted, though
  not required.  This behaves identically to the built-in function
  <tt class="function">int()</tt> when passed a string.  (Also note: for a more
  flexible interpretation of numeric literals, use the built-in
  function <tt class="function">eval()</tt><a id='l2h-365' xml:id='l2h-365'></a>.)
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-366' xml:id='l2h-366' class="function">atol</tt></b>(</nobr></td>
  <td><var>s</var><big>[</big><var>, base</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  <div class="versionnote"><b>Deprecated since release 2.0.</b>
Use the <tt class="function">long()</tt> built-in function.</div><p></p>
  Convert string <var>s</var> to a long integer in the given <var>base</var>.
  The string must consist of one or more digits, optionally preceded
  by a sign ("<tt class="samp">+</tt>" or "<tt class="samp">-</tt>").  The <var>base</var> argument has the
  same meaning as for <tt class="function">atoi()</tt>.  A trailing "<tt class="samp">l</tt>" or
  "<tt class="samp">L</tt>" is not allowed, except if the base is 0.  Note that when
  invoked without <var>base</var> or with <var>base</var> set to 10, this
  behaves identical to the built-in function
  <tt class="function">long()</tt><a id='l2h-367' xml:id='l2h-367'></a> when passed a string.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-368' xml:id='l2h-368' class="function">capitalize</tt></b>(</nobr></td>
  <td><var>word</var>)</td></tr></table></dt>
<dd>
  Return a copy of <var>word</var> with only its first character capitalized.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-369' xml:id='l2h-369' class="function">expandtabs</tt></b>(</nobr></td>
  <td><var>s</var><big>[</big><var>, tabsize</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  Expand tabs in a string replacing them by one or more spaces,
  depending on the current column and the given tab size.  The column
  number is reset to zero after each newline occurring in the string.
  This doesn't understand other non-printing characters or escape
  sequences.  The tab size defaults to 8.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-370' xml:id='l2h-370' class="function">find</tt></b>(</nobr></td>
  <td><var>s, sub</var><big>[</big><var>, start</var><big>[</big><var>,end</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  Return the lowest index in <var>s</var> where the substring <var>sub</var> is
  found such that <var>sub</var> is wholly contained in
  <code><var>s</var>[<var>start</var>:<var>end</var>]</code>.  Return <code>-1</code> on failure.
  Defaults for <var>start</var> and <var>end</var> and interpretation of
  negative values is the same as for slices.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-371' xml:id='l2h-371' class="function">rfind</tt></b>(</nobr></td>
  <td><var>s, sub</var><big>[</big><var>, start</var><big>[</big><var>, end</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  Like <tt class="function">find()</tt> but find the highest index.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-372' xml:id='l2h-372' class="function">index</tt></b>(</nobr></td>
  <td><var>s, sub</var><big>[</big><var>, start</var><big>[</big><var>, end</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  Like <tt class="function">find()</tt> but raise <tt class="exception">ValueError</tt> when the
  substring is not found.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-373' xml:id='l2h-373' class="function">rindex</tt></b>(</nobr></td>
  <td><var>s, sub</var><big>[</big><var>, start</var><big>[</big><var>, end</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  Like <tt class="function">rfind()</tt> but raise <tt class="exception">ValueError</tt> when the
  substring is not found.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-374' xml:id='l2h-374' class="function">count</tt></b>(</nobr></td>
  <td><var>s, sub</var><big>[</big><var>, start</var><big>[</big><var>, end</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  Return the number of (non-overlapping) occurrences of substring
  <var>sub</var> in string <code><var>s</var>[<var>start</var>:<var>end</var>]</code>.
  Defaults for <var>start</var> and <var>end</var> and interpretation of
  negative values are the same as for slices.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-375' xml:id='l2h-375' class="function">lower</tt></b>(</nobr></td>
  <td><var>s</var>)</td></tr></table></dt>
<dd>
  Return a copy of <var>s</var>, but with upper case letters converted to
  lower case.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-376' xml:id='l2h-376' class="function">split</tt></b>(</nobr></td>
  <td><var>s</var><big>[</big><var>, sep</var><big>[</big><var>, maxsplit</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  Return a list of the words of the string <var>s</var>.  If the optional
  second argument <var>sep</var> is absent or <code>None</code>, the words are
  separated by arbitrary strings of whitespace characters (space, tab, 
  newline, return, formfeed).  If the second argument <var>sep</var> is
  present and not <code>None</code>, it specifies a string to be used as the 
  word separator.  The returned list will then have one more item
  than the number of non-overlapping occurrences of the separator in
  the string.  The optional third argument <var>maxsplit</var> defaults to
  0.  If it is nonzero, at most <var>maxsplit</var> number of splits occur,
  and the remainder of the string is returned as the final element of
  the list (thus, the list will have at most <code><var>maxsplit</var>+1</code>
  elements).

<p>
The behavior of split on an empty string depends on the value of <var>sep</var>.
  If <var>sep</var> is not specified, or specified as <code>None</code>, the result will
  be an empty list.  If <var>sep</var> is specified as any string, the result will
  be a list containing one element which is an empty string.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-377' xml:id='l2h-377' class="function">rsplit</tt></b>(</nobr></td>
  <td><var>s</var><big>[</big><var>, sep</var><big>[</big><var>, maxsplit</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  Return a list of the words of the string <var>s</var>, scanning <var>s</var>
  from the end.  To all intents and purposes, the resulting list of
  words is the same as returned by <tt class="function">split()</tt>, except when the
  optional third argument <var>maxsplit</var> is explicitly specified and
  nonzero.  When <var>maxsplit</var> is nonzero, at most <var>maxsplit</var>
  number of splits - the <em>rightmost</em> ones - occur, and the remainder
  of the string is returned as the first element of the list (thus, the
  list will have at most <code><var>maxsplit</var>+1</code> elements).
  
<span class="versionnote">New in version 2.4.</span>

</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-378' xml:id='l2h-378' class="function">splitfields</tt></b>(</nobr></td>
  <td><var>s</var><big>[</big><var>, sep</var><big>[</big><var>, maxsplit</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  This function behaves identically to <tt class="function">split()</tt>.  (In the
  past, <tt class="function">split()</tt> was only used with one argument, while
  <tt class="function">splitfields()</tt> was only used with two arguments.)
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-379' xml:id='l2h-379' class="function">join</tt></b>(</nobr></td>
  <td><var>words</var><big>[</big><var>, sep</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  Concatenate a list or tuple of words with intervening occurrences of 
  <var>sep</var>.  The default value for <var>sep</var> is a single space
  character.  It is always true that
  "<tt class="samp">string.join(string.split(<var>s</var>, <var>sep</var>), <var>sep</var>)</tt>"  equals <var>s</var>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-380' xml:id='l2h-380' class="function">joinfields</tt></b>(</nobr></td>
  <td><var>words</var><big>[</big><var>, sep</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  This function behaves identically to <tt class="function">join()</tt>.  (In the past, 
  <tt class="function">join()</tt> was only used with one argument, while
  <tt class="function">joinfields()</tt> was only used with two arguments.)
  Note that there is no <tt class="method">joinfields()</tt> method on string
  objects; use the <tt class="method">join()</tt> method instead.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-381' xml:id='l2h-381' class="function">lstrip</tt></b>(</nobr></td>
  <td><var>s</var><big>[</big><var>, chars</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return a copy of the string with leading characters removed.  If
<var>chars</var> is omitted or <code>None</code>, whitespace characters are
removed.  If given and not <code>None</code>, <var>chars</var> must be a string;
the characters in the string will be stripped from the beginning of
the string this method is called on.

<span class="versionnote">Changed in version 2.2.3:
The <var>chars</var> parameter was added.  The <var>chars</var>
parameter cannot be passed in earlier 2.2 versions.</span>

</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-382' xml:id='l2h-382' class="function">rstrip</tt></b>(</nobr></td>
  <td><var>s</var><big>[</big><var>, chars</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return a copy of the string with trailing characters removed.  If
<var>chars</var> is omitted or <code>None</code>, whitespace characters are
removed.  If given and not <code>None</code>, <var>chars</var> must be a string;
the characters in the string will be stripped from the end of the
string this method is called on.

<span class="versionnote">Changed in version 2.2.3:
The <var>chars</var> parameter was added.  The <var>chars</var>
parameter cannot be passed in earlier 2.2 versions.</span>

</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-383' xml:id='l2h-383' class="function">strip</tt></b>(</nobr></td>
  <td><var>s</var><big>[</big><var>, chars</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return a copy of the string with leading and trailing characters
removed.  If <var>chars</var> is omitted or <code>None</code>, whitespace
characters are removed.  If given and not <code>None</code>, <var>chars</var>
must be a string; the characters in the string will be stripped from
the both ends of the string this method is called on.

<span class="versionnote">Changed in version 2.2.3:
The <var>chars</var> parameter was added.  The <var>chars</var>
parameter cannot be passed in earlier 2.2 versions.</span>

</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-384' xml:id='l2h-384' class="function">swapcase</tt></b>(</nobr></td>
  <td><var>s</var>)</td></tr></table></dt>
<dd>
  Return a copy of <var>s</var>, but with lower case letters
  converted to upper case and vice versa.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-385' xml:id='l2h-385' class="function">translate</tt></b>(</nobr></td>
  <td><var>s, table</var><big>[</big><var>, deletechars</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  Delete all characters from <var>s</var> that are in <var>deletechars</var> (if 
  present), and then translate the characters using <var>table</var>, which 
  must be a 256-character string giving the translation for each
  character value, indexed by its ordinal.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-386' xml:id='l2h-386' class="function">upper</tt></b>(</nobr></td>
  <td><var>s</var>)</td></tr></table></dt>
<dd>
  Return a copy of <var>s</var>, but with lower case letters converted to
  upper case.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-387' xml:id='l2h-387' class="function">ljust</tt></b>(</nobr></td>
  <td><var>s, width</var>)</td></tr></table></dt>
<dd>
<dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt class="function">rjust</tt></b>(</nobr></td>
  <td><var>s, width</var>)</td></tr></table></dt>
<dd><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt class="function">center</tt></b>(</nobr></td>
  <td><var>s, width</var>)</td></tr></table></dt>
<dd>  These functions respectively left-justify, right-justify and center
  a string in a field of given width.  They return a string that is at
  least <var>width</var> characters wide, created by padding the string
  <var>s</var> with spaces until the given width on the right, left or both
  sides.  The string is never truncated.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-390' xml:id='l2h-390' class="function">zfill</tt></b>(</nobr></td>
  <td><var>s, width</var>)</td></tr></table></dt>
<dd>
  Pad a numeric string on the left with zero digits until the given
  width is reached.  Strings starting with a sign are handled
  correctly.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-391' xml:id='l2h-391' class="function">replace</tt></b>(</nobr></td>
  <td><var>str, old, new</var><big>[</big><var>, maxreplace</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  Return a copy of string <var>str</var> with all occurrences of substring
  <var>old</var> replaced by <var>new</var>.  If the optional argument
  <var>maxreplace</var> is given, the first <var>maxreplace</var> occurrences are
  replaced.
</dl>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="4.1.3 string functions"
  href="node41.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="4.1 string  "
  href="module-string.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="4.2 re  "
  href="module-re.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="node41.html">4.1.3 String functions</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-string.html">4.1 string  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-re.html">4.2 re  </a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
